#!/usr/bin/env rc

pgrep emacs || emacs --daemon

if (~ $1 -) {
  shift
  buffer=`{mktemp} {
    cat > $buffer
    emacsclient -c $buffer $*
    cat $buffer
    rm $buffer >/dev/null >[2=1]
  }

  return
} else {
  emacsclient -c $*
}